package com.jy.appmarket.screenlock.model;

import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * 类说明：
 * 
 * @author jie.li
 * @date 2015-2-28
 * @version 1.0
 */
public class AppModel implements Parcelable, Comparable<AppModel> {
	private String first = "";
	private String appName;
	private String pkgName;
	private String className;
	private boolean selected;
	private boolean isFixed;
	private Drawable icon;

	public boolean isFixed() {
		return isFixed;
	}

	public void setFixed(boolean isFixed) {
		this.isFixed = isFixed;
	}

	public String getPkgName() {
		return pkgName;
	}

	public void setPkgName(String pkgName) {
		this.pkgName = pkgName;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public boolean isSelected() {
		return this.selected;
	}

	public void setSelected(boolean isSelected) {
		this.selected = isSelected;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public String getFirst() {
		return first;
	}

	public void setFirst(String first) {
		this.first = first;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int arg1) {
		dest.writeString(first);
		dest.writeString(appName);
		dest.writeString(pkgName);
		dest.writeString(className);

		if (selected) {
			dest.writeInt(1);
		} else {
			dest.writeInt(0);
		}

		if (isFixed) {
			dest.writeInt(1);
		} else {
			dest.writeInt(0);
		}
	}

	public static final Parcelable.Creator<AppModel> CREATOR = new Parcelable.Creator<AppModel>() {
		@Override
		public AppModel createFromParcel(Parcel source) {
			AppModel app = new AppModel();
			app.setFirst(source.readString());
			app.setAppName(source.readString());
			app.setPkgName(source.readString());
			app.setClassName(source.readString());
			app.setSelected((source.readInt() == 1));
			app.setFixed((source.readInt() == 1));
			return app;
		}

		@Override
		public AppModel[] newArray(int size) {
			return new AppModel[size];
		}
	};

	@Override
	public int compareTo(AppModel another) {
		return first.compareToIgnoreCase(another.first);
	}

	public Drawable getIcon() {
		return icon;
	}

	public void setIcon(Drawable icon) {
		this.icon = icon;
	}
}
